<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2018/5/29
 * Time: 20:00
 */

namespace app\model;


class Video extends Model
{
    public function __construct($db)
    {
        parent::__construct($db, "video");
    }

    public function getReadyHandleVideoMusics()
    {
        $this->db->select("*");
        $this->db->from("test");
        $query = $this->db->get();
        return $query->all();
    }


    /*=============================cron使用=====================*/
    //原始视频转码
    public function getReadyHandleVideoMusic($limit)
    {
        $this->db->select("video_id,video_url,video_no_music_url,transcode_video_url,transcode_video_no_music_url,transcode_no_music_zimu_video,no_music_zimu_video,video_music_url,cut_music_url,music_time,video_time,height,width");
        $this->db->from("video");
        $this->db->where(["transcode_status!="=>2,"transcode_count<="=>10,"status!="=>3]);
        $this->db->limit($limit);
        $query = $this->db->get();
        return $query->all();
    }



    /*=============================cron使用=====================*/
    //原始视频修改后再转码
    public function get_replace_material($limit)
    {
        $this->db->select("video_id,video_uuid,video_small_pic,transcode_video_url,transcode_video_no_music_url,cut_music_url,video_time,video_join_type,video_join_sub,video_desc,width,height,first_pic1");
        $this->db->from("video");
        $this->db->where(["is_update"=>2,"status!="=>3]);
        $this->db->limit($limit);
        $query = $this->db->get();
        return $query->all();
    }

    /**
     * 查询和原始素材视频uuid相同的视频
     */
    public function video_update($video_uuid){
        $this->db->select("id,quality_video_url,quatily_pic,duration,user_material_id,width1,height1");
        $this->db->from("quality_video");
        $this->db->where(["quality_uuid"=>$video_uuid]);
        $query = $this->db->get();
        return $query->all();
    }

    /**
     * 查询精品视频表需要转码的视频
     */
    public function video_transcode($limit){
        $this->db->select("id,quality_video_url,video_url,user_material_id");
        $this->db->from("quality_video");
        $this->db->where(["is_dubs"=>2,"transcode_status !="=>2,"transcode_count <"=>5]);
        $this->db->limit($limit);
        $query = $this->db->get();
        return $query->all();
    }
}